#include "precom.h"
#include "CartoonShader.h"


bool CartoonShader::CgShaderInit(HWND a_hWnd, CGcontext a_cg_context,
		CGprofile a_cg_vertProfile, CGprofile a_cg_fragProfile)
{
	cg_vertProg = cgCreateProgramFromFile(a_cg_context, CG_SOURCE, "Res/cartoon.cg",
					a_cg_vertProfile, "vertshader", 0);
	if( cg_vertProg == NULL ) {
		CGerror err = cgGetError();
		MessageBoxA(a_hWnd, cgGetErrorString(err), "Error CartoonVertCG", MB_OK);
		return false;
	}
	cg_fragProg = cgCreateProgramFromFile(a_cg_context, CG_SOURCE, "Res/cartoon.cg",
					a_cg_fragProfile, "fragshader", 0);
	if( cg_fragProg == NULL ) {
		CGerror err = cgGetError();
		MessageBoxA(a_hWnd, cgGetErrorString(err), "Error CartoonFragCG", MB_OK);
		return false;
	}
	
	cgGLLoadProgram(cg_vertProg);
	cgGLLoadProgram(cg_fragProg);
	
	cg_eyePos = cgGetNamedParameter(cg_fragProg, "EyePos");
	cg_modelViewMatrix = cgGetNamedParameter(cg_vertProg, "ModelView");
	cg_modelViewProjMatrix = cgGetNamedParameter(cg_vertProg, "ModelViewProj");
	return true;
}